﻿using OASystem.BLL.IService;
using OASystem.Common;
using OASystem.Model;
using OASystem.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace OASystem.Controllers
{
    public class Document_waitController : Controller
    {
        #region 注入
        private IDocument_wait _document_wait;
        public Document_waitController(IDocument_wait document_wait)
        {
            _document_wait = document_wait;
        }
        #endregion

        /// <summary>
        /// 显示列表
        /// </summary>
        /// <param name="page">页数</param>
        /// <param name="limit">记录数量</param>
        /// <param name="Publisher">发布人</param>
        /// <param name="TaskTiltle">任务标题</param>
        /// <param name="CompletionTime">发布时间</param>
        /// <returns></returns>
        public JsonResult Display(int page, int limit, string Publisher, string TaskTiltle, string CompletionTime)
        {
            Userinfo userinfo = AdminContext.context.adminUser;
            ResponseResult result = new ResponseResult();
            result = _document_wait.Display(userinfo.UserId, Publisher, TaskTiltle, CompletionTime);
            PageListResult<HandleQuery> a = new PageListResult<HandleQuery>();
            List<HandleQuery> admins = null;
            if (result != null)
            { admins = result.data; }
            if (admins == null)
            { a.count = 0; a.data = null; }
            else
            { a.count = admins.Count; a.data = admins.Skip((page - 1) * limit).Take(limit).ToList(); }
            a.code = 0;
            a.msg = "";
            return Json(a, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 完成状态
        /// </summary>
        /// <param name="id">所选行ID</param>
        /// <param name="status">修改后的状态</param>
        /// <returns></returns>
        public JsonResult Update(int id, int status)
        {
            ResponseResult result = new ResponseResult();
            result = _document_wait.Updater(id, status);
            return Json(result);
        }
    }
}